package vshevchuk;

public class dsFactory 
{
	static IDS root = null;
	
	private static void add( IDS ds )
	{
		ds.next = root;
		root = ds;
	}
	static
	{
		add( new ds_csv() );
		add( new ds_xml() );
		add( new ds_json() );
		add( new DS_Mock() );
	}
	
	public static IDS getInstance( String dsName )
	{				
		return root.check( dsName );
	}
}

/*
public class dsFactory 
{
	static IDS[] ads = null;
	
	static
	{
		ads = new IDS[4];
		ads[0] = new ds_csv();
		ads[1] = new ds_xml();
		ads[2] = new ds_json();
		ads[3] = new DS_Mock();
	}
	
	public static IDS getInstance( String dsName )
	{				
		IDS ds = null;
		switch( dsName )
		{
			case "CSV":  ds = ads[0]; break;
			case "XML":  ds = ads[1]; break;
			case "JSON": ds = ads[2]; break;
			case "MOCK": ds = ads[3]; break;
		}
		return ds;
	}
}
*/

/*
public class dsFactory 
{
	static IDS[] ads = null;
	
	private static void Init()
	{
		ads = new IDS[4];
		ads[0] = new ds_csv();
		ads[1] = new ds_xml();
		ads[2] = new ds_json();
		ads[3] = new DS_Mock();
	}
	
	public static IDS getInstance( String dsName )
	{		
		if( ads == null )
		{
			Init();
		}
			
		IDS ds = null;
		switch( dsName )
		{
			case "CSV":  ds = ads[0]; break;
			case "XML":  ds = ads[1]; break;
			case "JSON": ds = ads[2]; break;
			case "MOCK": ds = ads[3]; break;
		}
		return ds;
	}
}
*/

/*
public class dsFactory 
{
	public static IDS getInstance( String dsName )
	{
		IDS ds = null;
		switch( dsName )
		{
			case "CSV":  ds = new ds_csv(); break;
			case "XML":  ds = new ds_xml(); break;
			case "JSON": ds = new ds_json(); break;
			case "MOCK": ds = new DS_Mock(); break;
		}
		return ds;
	}
}
*/
